package org.lzh.controller;

import org.lzh.pojo.User;
import org.lzh.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = "login.action", method = RequestMethod.POST)
    public String login(@RequestParam("username")String username,
                        @RequestParam("password")String password ,
                        Model model){
        if(loginService.login(username,password)!=null){
            User user=loginService.login(username,password);
            model.addAttribute("user",user);
//            model.addAttribute("username",user.getUsername());
//            model.addAttribute("note",user.getNote());
//            model.addAttribute("imageLu",user.getImageLu());
//            System.out.println(user.getImageLu());
//            System.out.println(user.getImage());
//            System.out.println(user.getUsername());
//            System.out.println(user.getPassword());
            return "haha";
        }
        model.addAttribute("username",username);
        model.addAttribute("password",password);
        model.addAttribute("msg","账号或密码错误");
        return "login" ;
    }
}
